var pageContext = new PageContextDatatable(settings||{});
pageContext.setting.canShowRole = true;
pageContext.setting.canUpdateRole = true;
pageContext.getOtherOperBtn = function(id,label,record){
	var html = [];	
	if(pageContext.setting.canShowRole){
		html.push('<li>');
		html.push('<a href="javacript:void(0)" instance="'+record.instanceId+'" url="'+window.global.getFinalUrl(window.global.ctx+'/auth/grouprole/toedit?groupId='+record.id)+'" label="'+label+'"  val="'+id+'" class="tooltip-success propBtn" data-rel="tooltip" title="角色">');
		html.push('<span class="green">');
		html.push('<i class="ace-icon fa fa-flask bigger-120"></i>');
		html.push('</span>');
		html.push('</a>');
		html.push('</li>');
	}
	return html.join("");
}
pageContext.getOtherPingPuOperBtn = function(id,label,record){
	var html = [];
	if(pageContext.setting.canShowRole){
		html.push('<button class="btn btn-xs btn-info propBtn" url="'+window.global.getFinalUrl(window.global.ctx+'/auth/grouprole/toedit?groupId='+record.id)+'" instance="'+record.instanceId+'"  label="'+label+'" val="'+id+'" title="角色">');
		html.push('<i class="ace-icon fa fa-flask bigger-120"></i>');
		html.push('</button>');
	}
	return html.join("");
}
pageContext.renderAfterEventOther = function(){
	$('#'+pageContext.setting.tableId+' >tbody').on("click","tr > td .propBtn",function(e){
		e.stopPropagation();
		 var val = $(this).attr("val");
		 var label = $(this).attr("label");
		 var instance = $(this).attr("instance");
	      var url = ($(this).attr("url"));
		 url = window.global.addPara(url,"instanceId",instance,true);
		 load(url,"page-content",true,"用户组【"+label+"】"+"角色",function(){
				
		 });
		 return false;
	});
}
pageContext.toAdd = function(option){
	var action = window.global.getFinalUrl(pageContext.setting.toAddUrl);
	load(action,"page-content",true,"新增"+pageContext.modelName,function(){
		
	});
}
pageContext.toDetail = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toDetailUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,pageContext.modelName+"详情",function(){
		
	});
}
pageContext.toUpdate = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toUpdateUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,"修改"+pageContext.modelName,function(){
		
	});
}
jQuery(function($) {
   pageContext.init();

	 $(document).find("input").each(function(){
		 $(this).attr("autocomplete","off");
	 });
   var layero = $("#searchForm");
	layero.find('select[novalid!="true"]').each(function(){
		var novalid = $(this).attr("noconvert");
		if(novalid!="true"){
			var $span = layero.find(this).select2({
	            language: "zh-CN"
		            ,matcher:select2Matcher})
	            .next("span")
	            ;
		}
	  });
}); 
